It's an adverbial locution. The question is what. It is used just like "at most", "to the most", and would then be quantity, perhaps so. So clearly it should be "how much". But it's my opinion.
when a lot